
        <!DOCTYPE html>
        <html lang="en">
        <head>
            <meta charset="UTF-8">
            <meta http-equiv="X-UA-Compatible" content="IE=edge">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <title>Document</title>
        </head>
        <body>
            <section>
                <!-- &quot;      ____                       ______       &quot; -->
<!-- &quot;     &#x2F; __ ____ _____ ____      &#x2F;_  __&#x2F;____   &quot; -->
<!-- &quot;    &#x2F; &#x2F;_&#x2F; &#x2F; __ `&#x2F; __ `&#x2F; _ ______&#x2F; &#x2F; &#x2F; ___&#x2F;   &quot; -->
<!-- &quot;   &#x2F; ____&#x2F; &#x2F;_&#x2F; &#x2F; &#x2F;_&#x2F; &#x2F;  __&#x2F;_____&#x2F; &#x2F; &#x2F; &#x2F;       &quot; -->
<!-- &quot;  &#x2F;_&#x2F;    __,_&#x2F;__, &#x2F;___&#x2F;     &#x2F;_&#x2F; &#x2F;_&#x2F;        &quot; -->
<!-- &quot;              &#x2F;____&#x2F;                          &quot; -->
<!-- &quot;                                              &quot; -->
<br/><br/>
  <p>
    <span>qemu</span>
    <span>qemu开源虚拟机</span>
    <span>qemu</span>
  </p>
<b>NAME</b>
    <section style="margin-left:8%;">
    <strong>qemu</strong>
    - This is generated by page-tr
<br/><br/>
    </section>
<b>SYNOPSIS</b>
    <section style="margin-left:8%;">
    qemu
<br/><br/>
    </section>
<b>Examples</b>
    <section style="margin-left:8%;">
<br/><br/>
    <strong>示例</strong>
<pre>
    qemu-system-aarch64 
        -M virt-2.9 
        -cpu cortex-a72 
        -smp 8 
        -m 2G 
        -device nec-usb-xhci 
        -device usb-kbd 
        -device usb-tablet 
        -device virtio-blk,drive=system 
        -drive if=none,id=system,file=&#x2F;sdcard&#x2F;system.vhdx 
        -vnc :0 
        -net user 
        -net nic,model=virtio 
        -device VGA 
        -pflash &#x2F;sdcard&#x2F;QEMU_EFI.img 
        -pflash &#x2F;sdcard&#x2F;QEMU_VARS.img
</pre>
<br/><br/>
<pre>
    qemu-system-aarch64 
        -smp 2 
        -m 1024 
        -M virt 
        -cpu cortex-a57 
        -bios &#x2F;usr&#x2F;share&#x2F;qemu-efi-aarch64&#x2F;QEMU_EFI.fd 
        -nographic 
        -device virtio-blk-device,drive=image 
        -drive if=none,id=image,file=ubuntu-16.04-server-cloudimg-arm64-uefi1.img,format=qcow2 
        -device virtio-blk-device,drive=cloud 
        -drive if=none,id=cloud,file=cloud.img,format=qcow2 
        -device e1000,netdev=net0 
        -netdev user,id=net0,hostfwd=tcp:127.0.0.1:2222-:22
</pre>
<br/><br/>
    <strong>安装？</strong>
<pre>
    $QEMU&#x2F;qemu-system-aarch64 
        -serial mon:stdio 
        -M virt,highmem=off 
        -accel hvf 
        -cpu cortex-a72 
        -smp 4 
        -m 4096 
        -drive file=.&#x2F;pflash0.img,format=raw,if=pflash,readonly=on 
        -drive file=.&#x2F;pflash1.img,format=raw,if=pflash 
        -device virtio-scsi-pci 
        -device virtio-gpu-pci 
        -device qemu-xhci 
        -device usb-kbd 
        -device usb-tablet 
        -drive file=.&#x2F;disk.qcow2,if=none,id=boot,cache=writethrough 
        -device nvme,drive=boot,serial=boot 
        -drive if=none,id=cd,file=debian-10.7.0-arm64-xfce-CD-1.iso,media=cdrom 
        -device scsi-cd,drive=cd 
        -display default,show-cursor=on
</pre>
<br/><br/>
    <strong>启动？</strong>
<pre>
    $QEMU&#x2F;qemu-system-aarch64 
        -monitor stdio 
        -M virt,highmem=off 
        -accel hvf 
        -cpu cortex-a72 
        -smp 4 
        -m 4096 
        -drive file=.&#x2F;pflash0.img,format=raw,if=pflash,readonly=on 
        -drive file=.&#x2F;pflash1.img,format=raw,if=pflash 
        -device virtio-gpu-pci 
        -device virtio-scsi-pci 
        -device qemu-xhci 
        -device usb-kbd 
        -device usb-tablet 
        -drive file=.&#x2F;disk.qcow2,if=none,id=boot,cache=writethrough 
        -device nvme,drive=boot,serial=boot 
        -display default,show-cursor=on 
        -nic user,model=virtio
</pre>
<br/><br/>
    <strong>错误</strong>
<pre>
    qemu-system-aarch64 
        -clock dynticks 
        -localtime 
        -hda linux.qcow2 
        -cdrom debian.iso 
        -boot d 
        -m 1024
</pre>
<br/><br/>
<pre>
    .&#x2F;qemu-system-aarch64 
        -smp cpus=1,cores=1,threads=1
        -M virt
        -cpu cortex-a57
        -hda ubuntu.img 
        -boot d 
        -device VGA
        -cdrom &#x2F;Volumes&#x2F;T7&#x2F;杂物&#x2F;镜像文件&#x2F;ubuntu-20.10-live-server-arm64.iso 
        -m 640
</pre>
<br/><br/>
    </section>
<b>qemu 参数速读</b>
    <section style="margin-left:8%;">
<pre>
    qemu-system-aarch64 
        -M  virt 
        -cpu cortex-a53 
        -smp 2 
        -m 4096M  
        -kernel &#x2F;tmp&#x2F;arch&#x2F;arm64&#x2F;boot&#x2F;Image.gz   
        -nographic  
        -append &quot;console=ttyAMA0 init=&#x2F;linuxrc ignore_loglevel&quot;   
        -initrd &#x2F;tmp&#x2F;rootfs&#x2F;rootfs.img  
        -S 
        -gdb tcp::9000
    
    -smp 核数目
    -m 物理内存大小
    -kernel 内核压缩镜像位置
    -initrd rootfs位置
    -nographic 不使用图形界面，不加可能会因为无法启动图形界面而失败
    -append cmdline启动参数
    -S 在入口处阻塞CPU
    -gdb tcp::xxxx 指定通信通道为 本地tcp通道(因为是在同一个机器上)，端口号为xxxx，如果不需要指定端口号可以用-s 代替
</pre>
<br/><br/>
    </section>
<b>qemu 参数说明</b>
    <section style="margin-left:8%;">
    <b>-smp [cpus=]n[,cores=cores][,threads=threads][,dies=dies][,sockets=sockets][,maxcpus=maxcpus]</b>
        <section style="margin-left:8%;">
        模拟一个有n个cpu的SMP系统。操作步骤本地PC最多支持255个cpu。在Sparc32目标上，Linux将可用cpu的数量限制为4个。对于PC目标，可以指定每个模的内核数、每个核的线程数、每个包的模数和插槽的总数。将计算缺失的值。如果给定了三个值中的任意值，则可以省略cpu总数n。maxcpus:热插拔的最大cpu个数。
<br/><br/>
        <br/></section>
    <b>-boot [order=drives][,once=drives][,menu=on|off][,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_timeout][,strict=on|off]</b>
        <section style="margin-left:8%;">
        将引导顺序驱动器指定为驱动器号字符串。有效的驱动器号取决于目标体系结构。x86 PC使用:a、b(软盘1、2)、c(第一块硬盘)、d(第一张CD-ROM)、n-p(以太网卡1-4)，硬盘启动为默认启动。要只在第一次启动时应用特定的引导顺序，请指定一次。注意，order或once参数不应该与设备的bootindex属性一起使用，因为固件实现通常不同时支持这两个参数。
<br/><br/>
        交互式引导菜单&#x2F;提示可以通过menu=on启用，只要固件&#x2F;BIOS支持它们。默认是非交互式引导。
<br/><br/>
        如果固件&#x2F; bios支持splash=sp_name选项和menu=on选项，可以将splash图片传递给bios，使用户可以将其显示为logo。目前用于X86系统的Seabios支持它。限制:splash文件可以是jpeg文件或24bpp格式的BMP文件(true color)。支持SVGA模式的分辨率，建议设置为320x240、640x480、800x640。
<br/><br/>
        可以将超时传递给bios，当引导失败时，guest将暂停rb_timeout ms，然后重新启动。如果rb_timeout为&#x27; -1 &#x27;，guest将不会重新启动，qemu默认将&#x27; -1 &#x27;传递给bios。目前用于X86系统的Seabios支持它。
<br/><br/>
        在固件&#x2F;BIOS支持的情况下，通过strict=进行严格引导。这只在引导优先级被引导索引选项改变时有效。默认是非严格引导。
<br/><br/>
<pre>
    # try to boot from network first, then from hard disk
    qemu-system-x86_64 -boot order=nc
    # boot from CD-ROM first, switch back to default order after reboot
    qemu-system-x86_64 -boot once=d
    # boot with a splash picture for 5 seconds.
    qemu-system-x86_64 -boot menu=on,splash=&#x2F;root&#x2F;boot.bmp,splash-time=5000
</pre>
        注意:传统格式&#x27; -boot drives &#x27;仍然被支持，但它的使用是不鼓励的，因为它可能会从未来的版本中删除。
<br/><br/>
        <br/></section>
    <b>-m [size=]megs[,slots=n,maxmem=size]</b>
        <section style="margin-left:8%;">
        设置客户启动RAM大小为兆。缺省值是128 MiB。可以选择使用“M”或“G”后缀分别表示以兆字节或千兆字节为单位的值。可选的对插槽，maxmem可以用来设置热插拔内存插槽的数量和最大内存数量。注意，maxmem必须与页面大小对齐。
<br/><br/>
        例如，以下命令将客户启动内存大小设置为1GB，创建3个插槽来热插额外的内存，并将客户可以达到的最大内存设置为4GB:
<br/><br/>
<pre>
    qemu-system-x86_64 -m 1G,slots=3,maxmem=4G
</pre>
        如果没有指定插槽和maxmem，内存热插拔将不会被启用，客户启动RAM将永远不会增加。
<br/><br/>
        <strong>-mem-path path</strong>
        从路径中临时创建的文件分配来宾RAM。
<br/><br/>
        <strong>-mem-prealloc</strong>
        使用-mem-path时预分配内存。
<br/><br/>
        <br/></section>
    <b>-k language</b>
        <section style="margin-left:8%;">
        使用键盘布局语言(例如fr为法语)。这个选项只有在不容易获得原始的PC密钥代码的地方才需要(例如，在mac上，与一些X11服务器或VNC或诅咒显示)。你通常不需要在PC&#x2F;Linux或PC&#x2F;Windows主机上使用它。
<br/><br/>
        可用的布局如下:
<pre>
    ar  de-ch  es  fo     fr-ca  hu  ja  mk     no  pt-br  sv
    da  en-gb  et  fr     fr-ch  is  lt  nl     pl  ru     th
    de  en-us  fi  fr-be  hr     it  lv  nl-be  pt  sl     tr
</pre>
<br/><br/>
<br/><br/>
        <br/></section>
    <b>-vga</b>
        <section style="margin-left:8%;">
        选择要模拟的VGA卡类型。type的有效值是
<br/><br/>
        <strong>cirrus</strong>
            <section style="margin-left:4%">
        Cirrus Logic GD5446 Video card. All Windows versions starting from Windows 95 should recognize and use this graphic card. For optimal performances, use 16 bit color depth in the guest and the host OS. (This card was the default before QEMU 2.2)
<br/><br/>
        Cirrus Logic GD5446视频卡。从Windows 95开始的所有Windows版本都应该识别并使用此显卡。为了获得最佳性能，在来宾操作系统和主机操作系统中使用16位颜色深度。(这张卡在QEMU 2.2之前是默认的)
            </section>
        <strong>std</strong>
            <section style="margin-left:4%">
        Standard VGA card with Bochs VBE extensions. If your guest OS supports the VESA 2.0 VBE extensions (e.g. Windows XP) and if you want to use high resolution modes (&gt;= 1280x1024x16) then you should use this option. (This card is the default since QEMU 2.2)
<br/><br/>
        带有Bochs VBE扩展的标准VGA卡。如果你的客户操作系统支持VESA 2.0 VBE扩展(例如Windows XP)，如果你想使用高分辨率模式(&gt;= 1280x1024x16)，那么你应该使用这个选项。(这张卡是QEMU 2.2以来的默认卡)
            </section>
        <strong>vmware</strong>
            <section style="margin-left:4%">
        VMWare SVGA-II compatible adapter. Use it if you have sufficiently recent XFree86&#x2F;XOrg server or Windows guest with a driver for this card.
<br/><br/>
        VMWare SVGA-II兼容适配器。如果您有足够最新的XFree86&#x2F;XOrg服务器或Windows客户端，并有此卡的驱动程序，请使用它。
            </section>
        <strong>qxl</strong>
            <section style="margin-left:4%">
        QXL paravirtual graphic card. It is VGA compatible (including VESA 2.0 VBE support). Works best with qxl guest drivers installed though. Recommended choice when using the spice protocol.
<br/><br/>
        QXL半虚拟显卡。它兼容VGA(包括VESA 2.0 VBE支持)。安装qxl客户驱动程序后效果最好。使用香料协议时推荐的选择。
            </section>
        <strong>tcx</strong>
            <section style="margin-left:4%">
        (sun4m only) Sun TCX framebuffer. This is the default framebuffer for sun4m machines and offers both 8-bit and 24-bit colour depths at a fixed resolution of 1024x768.
<br/><br/>
        (仅sun4m) Sun TCX framebuffer。这是sun4m机器的默认帧缓冲区，提供8位和24位颜色深度，固定分辨率为1024x768。
            </section>
        <strong>cg3</strong>
            <section style="margin-left:4%">
        (sun4m only) Sun cgthree framebuffer. This is a simple 8-bit framebuffer for sun4m machines available in both 1024x768 (OpenBIOS) and 1152x900 (OBP) resolutions aimed at people wishing to run older Solaris versions.
            </section>
        <strong>virtio</strong>
            <section style="margin-left:4%">
        Virtio VGA card.
            </section>
        <strong>none</strong>
            <section style="margin-left:4%">
        Disable VGA card.
            </section>
<br/><br/>
        <br/></section>
    <b>-monitor</b>
        <section style="margin-left:8%;">
        将监视器重定向到主机设备dev(与串口相同的设备)。默认的设备是图形模式下的vc和非图形模式下的stdio。使用-monitor none禁用默认monitor。
<br/><br/>
<br/>        </section>
    </section>
<b>qemu Display options</b>
    <section style="margin-left:8%;">
    <b>-display type</b>
        <section style="margin-left:8%;">
        选择要使用的显示类型。这个选项是旧样式-sdl&#x2F;-curses&#x2F;…选项的替代。使用-display help列出可用的显示类型。type的有效值是
<br/><br/>
        <strong>sdl</strong>
            <section style="margin-left:4%">
        Display video output via SDL (usually in a separate graphics window; see the SDL documentation for other possibilities).
            </section>
        <strong>curses</strong>
            <section style="margin-left:4%">
        Display video output via curses. For graphics device models which support a text mode, QEMU can display this output using a curses&#x2F;ncurses interface. Nothing is displayed when the graphics device is in graphical mode or if the graphics device does not support a text mode. Generally only the VGA device models support text mode. The font charset used by the guest can be specified with the charset option, for example charset=CP850 for IBM CP850 encoding. The default is CP437.
            </section>
        <strong>none</strong>
            <section style="margin-left:4%">
        Do not display video output. The guest will still see an emulated graphics card, but its output will not be displayed to the QEMU user. This option differs from the -nographic option in that it only affects what is done with video output; -nographic also changes the destination of the serial and parallel port data.
            </section>
        <strong>gtk</strong>
            <section style="margin-left:4%">
        Display video output in a GTK window. This interface provides drop-down menus and other UI elements to configure and control the VM during runtime.
            </section>
        <strong>vnc</strong>
            <section style="margin-left:4%">
        Start a VNC server on display &lt;arg&gt;
            </section>
        <strong>egl-headless</strong>
            <section style="margin-left:4%">
        Offload all OpenGL operations to a local DRI device. For any graphical display, this display needs to be paired with either VNC or SPICE displays.
            </section>
        <strong>spice-app</strong>
            <section style="margin-left:4%">
        Start QEMU as a Spice server and launch the default Spice client application. The Spice server will redirect the serial consoles and QEMU monitors. (Since 4.0)
            </section>
<br/><br/>
<br/><br/>
<br/>        </section>
    </section>
<b>qemu 版本</b>
    <section style="margin-left:8%;">
    qemu-system-aarch64 -version
<br/><br/>
    </section>
<b>qemu 转发端口 22 -&gt; localhost:2222</b>
    <section style="margin-left:8%;">
    这种方法可以在主机的qemu进程监听一个端口，主机可通过这个端口与客户机对应的端口通讯。
        <section style="margin-left:4%">
    -netdev user,id=net0,hostfwd=tcp:127.0.0.1:2222-:22
        </section>
<br/><br/>
    在客户机对外开放ftp服务，ftp主动模式的命令端口是21，数据端口是20，就必须写两个hostfwd参数并用逗号隔开：
        <section style="margin-left:4%">
    -netdev user,id=n0,hostfwd=::1020-:20,hostfwd=::1021-:21
        </section>
<br/><br/>
    </section>
<b>qemu 不设置 -bios QEMU_EFI.fd</b>
    <section style="margin-left:8%;">
<br/><br/>
<br/><br/>
    </section>
<b>qemu-system-aarch64 启动虚拟机</b>
    <section style="margin-left:8%;">
<br/><br/>
    </section>
</section>

            </section>
            <style>
                p:first-of-type{
                    margin-bottom: 15px;
                    text-align: center;
                }
                p:first-of-type span:first-child {
                    float: left;
                }
                p:first-of-type span:last-child  {
                    float: right;
                }
            </style>
        </body>
        </html>
        